<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 10.2.&nbsp; Signal Concepts</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch10lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch10lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch10lev1sec2"></a>
<h3 class="docSection1Title">10.2. Signal Concepts</h3>
<p class="docText">First, every signal has a name. These names all begin with the three characters <tt>SIG</tt>. For example, <tt>SIGABRT</tt> is the abort signal that is generated when a process calls the <tt>abort</tt> function. <tt>SIGALRM</tt> is the alarm signal that is generated when the timer set by the <tt>alarm</tt> function goes off. Version 7 had 15 different signals; SVR4 and 4.4BSD both have 31 different signals. FreeBSD 5.2.1, Mac OS X 10.3, and Linux 2.4.22 support 31 different <a name="idd1e66863"></a><a name="idd1e66868"></a><a name="idd1e66873"></a><a name="idd1e66876"></a><a name="idd1e66881"></a><a name="idd1e66886"></a><a name="idd1e66889"></a><a name="idd1e66892"></a><a name="idd1e66895"></a><a name="idd1e66900"></a><a name="idd1e66905"></a><a name="idd1e66910"></a><a name="idd1e66915"></a><a name="idd1e66920"></a><a name="idd1e66925"></a><a name="idd1e66928"></a><a name="idd1e66933"></a>signals, whereas Solaris 9 supports 38 different signals. Both Linux and Solaris, however, support additional application-defined signals as real-time extensions (the real-time extensions in POSIX aren't covered in this book; refer to Gallmeister [<a class="docLink" href="bib01.html#biblio01_020">1995</a>] for more information).</P>
<p class="docText">These names are all defined by positive integer constants (the signal number) in the header <tt>&lt;signal.h&gt;</tt>.</P>
<blockquote>
<p class="docText">Implementations actually define the individual signals in an alternate header file, but this header file is included by <tt>&lt;signal.h&gt;</tt>. It is considered bad form for the kernel to include header files meant for user-level applications, so if the applications and the kernel both need the same definitions, the information is placed in a kernel header file that is then included by the user-level header file. Thus, both FreeBSD 5.2.1 and Mac OS X 10.3 define the signals in <tt>&lt;sys/signal.h&gt;</tt>. Linux 2.4.22 defines the signals in <tt>&lt;bits/signum.h&gt;</tt>, and Solaris 9 defines them in <tt>&lt;sys/iso/signal_iso.h&gt;</tt>.</p>
</blockquote>
<p class="docText">No signal has a signal number of 0. We'll see in <a class="docLink" href="ch10lev1sec9.html#ch10lev1sec9">Section 10.9</a> that the <tt>kill</tt> function uses the signal number of 0 for a special case. POSIX.1 calls this value the <span class="docEmphasis">null signal</span>.</P>
<p class="docText">Numerous conditions can generate a signal.</P>
<UL><li><p class="docList">The terminal-generated signals occur when users press certain terminal keys. Pressing the DELETE key on the terminal (or Control-C on many systems) normally causes the interrupt signal (<tt>SIGINT</tt>) to be generated. This is how to stop a runaway program. (We'll see in <a class="docLink" href="ch18.html#ch18">Chapter 18</a> how this signal can be mapped to any character on the terminal.)</P></LI><LI><p class="docList">Hardware exceptions generate signals: divide by 0, invalid memory reference, and the like. These conditions are usually detected by the hardware, and the kernel is notified. The kernel then generates the appropriate signal for the process that was running at the time the condition occurred. For example, <tt>SIGSEGV</tt> is generated for a process that executes an invalid memory reference.</p></LI><li><p class="docList">The <tt>kill</tt>(2) function allows a process to send any signal to another process or process group. Naturally, there are limitations: we have to be the owner of the process that we're sending the signal to, or we have to be the superuser.</P></LI><LI><p class="docList">The <tt>kill</tt>(1) command allows us to send signals to other processes. This program is just an interface to the <tt>kill</tt> function. This command is often used to terminate a runaway background process.</p></LI><LI><p class="docList">Software conditions can generate signals when something happens about which the process should be notified. These aren't hardware-generated conditions (as is the divide-by-0 condition), but software conditions. Examples are <tt>SIGURG</tt> (generated when out-of-band data arrives over a network connection), <tt>SIGPIPE</tt> (generated when a process writes to a pipe after the reader of the pipe has terminated), and <tt>SIGALRM</tt> (generated when an alarm clock set by the process expires).</p></LI></UL>
<p class="docText">Signals are classic examples of asynchronous events. Signals occur at what appear to be random times to the process. The process can't simply test a variable (such as <tt>errno</tt>) to see whether a signal has occurred; instead, the process has to tell the kernel &quot;if and when this signal occurs, do the following.&quot;</p>
<p class="docText"><a name="idd1e67047"></a><a name="idd1e67052"></a><a name="idd1e67057"></a><a name="idd1e67062"></a><a name="idd1e67067"></a><a name="idd1e67072"></a><a name="idd1e67077"></a><a name="idd1e67080"></a><a name="idd1e67085"></a><a name="idd1e67090"></a><a name="idd1e67093"></a>We can tell the kernel to do one of three things when a signal occurs. We call this the <span class="docEmphasis">disposition</span> of the signal, or the <span class="docEmphasis">action</span> associated with a signal.</p>
<div style="font-weight:bold"><ol class="docList" type="1"><li><div style="font-weight:normal"><p class="docList">Ignore the signal. This works for most signals, but two signals can never be ignored: <tt>SIGKILL</tt> and <tt>SIGSTOP</tt>. The reason these two signals can't be ignored is to provide the kernel and the superuser with a surefire way of either killing or stopping any process. Also, if we ignore some of the signals that are generated by a hardware exception (such as illegal memory reference or divide by 0), the behavior of the process is undefined.</p></div></LI><li><div style="font-weight:normal"><p class="docList">Catch the signal. To do this, we tell the kernel to call a function of ours whenever the signal occurs. In our function, we can do whatever we want to handle the condition. If we're writing a command interpreter, for example, when the user generates the interrupt signal at the keyboard, we probably want to return to the main loop of the program, terminating whatever command we were executing for the user. If the <tt>SIGCHLD</tt> signal is caught, it means that a child process has terminated, so the signal-catching function can call <tt>waitpid</tt> to fetch the child's process ID and termination status. As another example, if the process has created temporary files, we may want to write a signal-catching function for the <tt>SIGTERM</tt> signal (the termination signal that is the default signal sent by the <tt>kill</tt> command) to clean up the temporary files. Note that the two signals <tt>SIGKILL</tt> and <tt>SIGSTOP</tt> can't be caught.</P></div></li><LI><div style="font-weight:normal"><p class="docList">Let the default action apply. Every signal has a default action, shown in <a class="docLink" href="#ch10fig01">Figure 10.1</a>. Note that the default action for most signals is to terminate the process.</p></div></li></ol></div>
<a name="ch10fig01"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 10.1. UNIX System signals</h5></caption><colgroup><col width="75"><col width="225"><col width="40"><col width="25"><col width="25"><col width="25"><col width="25"><col width="25"><col width="50"></colgroup><thead><tr><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Name</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="bottomBorder thead" scope="col" align="left" valign="middle"><p class="docText"><span class="docEmphRoman">ISO C</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="middle"><p class="docText"><span class="docEmphRoman">SUS</span></p></th><th class="bottomBorder thead" scope="col" align="left" valign="bottom"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></p></th><th class="bottomBorder thead" scope="col" align="left" valign="bottom"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></p></th><th class="bottomBorder thead" scope="col" align="left" valign="bottom"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="bottom"><p class="docText"><span class="docEmphRoman">Solaris 9</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Default action</span></p></th></tr></thead><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGABRT</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">abnormal termination (<tt>abort</tt>)</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGALRM</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">timer expired (<tt>alarm</tt>)</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGBUS</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">hardware fault</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGCANCEL</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">threads library internal use</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">ignore</P></td></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGCHLD</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">change in status of child</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGCONT</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">continue stopped process</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">continue/ignore</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGEMT</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">hardware fault</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGFPE</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">arithmetic exception</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGFREEZE</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">checkpoint freeze</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="left" valign="top"><p class="docText">ignore</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGHUP</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">hangup</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGILL</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">illegal instruction</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGINFO</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">status request from keyboard</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGINT</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">terminal interrupt character</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGIO</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">asynchronous I/O</p></td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate/ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGIOT</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">hardware fault</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGKILL</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">termination</P></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGLWP</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">threads library internal use</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">ignore</P></td></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGPIPE</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">write to pipe with no readers</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGPOLL</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">pollable event (<tt>poll</tt>)</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="left" valign="top"><p class="docText">XSI</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGPROF</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">profiling time alarm (<tt>setitimer</tt>)</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGPWR</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">power fail/restart</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate/ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGQUIT</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">terminal quit character</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGSEGV</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">invalid memory reference</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</p></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGSTKFLT</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">coprocessor stack fault</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGSTOP</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">stop</P></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">stop process</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGSYS</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">invalid system call</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="left" valign="top"><p class="docText">XSI</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGTERM</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">termination</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">terminate</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGTHAW</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">checkpoint thaw</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGTRAP</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">hardware fault</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top"><p class="docText">XSI</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate+core</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGTSTP</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">terminal stop character</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">stop process</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGTTIN</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">background read from control tty</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">stop process</p></td></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGTTOU</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">background write to control tty</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">stop process</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGURG</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">urgent condition (sockets)</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGUSR1</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">user-defined signal</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">terminate</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGUSR2</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">user-defined signal</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGVTALRM</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">virtual time alarm (<tt>setitimer</tt>)</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="left" valign="top"><p class="docText">XSI</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate</p></TD></TR><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGWAITING</tt></p></td><TD class="rightBorder" align="left" valign="top"><p class="docText">threads library internal use</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGWINCH</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">terminal window size change</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGXCPU</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">CPU limit exceeded (<tt>setrlimit</tt>)</P></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">terminate+core/ignore</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGXFSZ</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">file size limit exceeded (<tt>setrlimit</tt>)</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="left" valign="top"><p class="docText">XSI</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">terminate+core/ignore</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>SIGXRES</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">resource control exceeded</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">ignore</p></TD></TR></table></P><br>
<p class="docText"><a class="docLink" href="#ch10fig01">Figure 10.1</a> lists the names of all the signals, an indication of which systems support the signal, and the default action for the signal. The SUS column contains &#8226; if the signal is defined as part of the base POSIX.1 specification and <span class="docEmphStrong">XSI</span> if it is defined as an XSI extension to the base.</P>
<p class="docText">When the default action is labeled &quot;terminate+core,&quot; it means that a memory image of the process is left in the file named <tt>core</tt> of the current working directory of the process. (Because the file is named <tt>core</tt>, it shows how long this feature has been part of the UNIX System.) This file can be used with most UNIX System debuggers to examine the state of the process at the time it terminated.</p>
<blockquote>
<p class="docText">The generation of the <tt>core</tt> file is an implementation feature of most versions of the UNIX System. Although this feature is not part of POSIX.1, it is mentioned as a potential implementation-specific action in the Single UNIX Specification's XSI extension.</P>
<p class="docText">The name of the core file varies among implementations. On FreeBSD 5.2.1, for example, the core file is named <span class="docEmphasis">cmdname</span>.core, where <span class="docEmphasis">cmdname</span> is the name of the command corresponding to the process that received the signal. On Mac OS X 10.3, the core file is named core.<span class="docEmphasis">pid</span>, where <span class="docEmphasis">pid</span> is the ID of the process that received the signal. (These systems allow the core filename to be configured via a <tt>sysctl</tt> parameter.)</P>
<p class="docText">Most implementations leave the core file in the current working directory of the corresponding process; Mac OS X places all core files in <tt>/cores</tt> instead.</P>
</blockquote>
<p class="docText"><a name="idd1e68788"></a><a name="idd1e68791"></a><a name="idd1e68794"></a><a name="idd1e68797"></a><a name="idd1e68802"></a><a name="idd1e68807"></a><a name="idd1e68812"></a><a name="idd1e68817"></a><a name="idd1e68822"></a><a name="idd1e68827"></a><a name="idd1e68832"></a><a name="idd1e68837"></a><a name="idd1e68842"></a><a name="idd1e68847"></a><a name="idd1e68852"></a><a name="idd1e68857"></a><a name="idd1e68862"></a><a name="idd1e68867"></a><a name="idd1e68872"></a><a name="idd1e68877"></a><a name="idd1e68882"></a><a name="idd1e68887"></a><a name="idd1e68892"></a><a name="idd1e68897"></a><a name="idd1e68902"></a><a name="idd1e68907"></a><a name="idd1e68912"></a><a name="idd1e68917"></a><a name="idd1e68922"></a><a name="idd1e68927"></a><a name="idd1e68932"></a><a name="idd1e68937"></a><a name="idd1e68942"></a><a name="idd1e68947"></a><a name="idd1e68952"></a><a name="idd1e68957"></a><a name="idd1e68962"></a><a name="idd1e68967"></a><a name="idd1e68972"></a><a name="idd1e68977"></a><a name="idd1e68982"></a>The core file will not be generated if (a) the process was set-user-ID and the current user is not the owner of the program file, or (b) the process was set-group-ID and the current user is not the group owner of the file, (c) the user does not have permission to write in the current working directory, (d) the file already exists and the user does not <a name="idd1e68987"></a><a name="idd1e68992"></a><a name="idd1e68997"></a><a name="idd1e69002"></a><a name="idd1e69007"></a><a name="idd1e69012"></a><a name="idd1e69017"></a>have permission to write to it, or (e) the file is too big (recall the <tt>RLIMIT_CORE</tt> limit in <a class="docLink" href="ch07lev1sec11.html#ch07lev1sec11">Section 7.11</a>). The permissions of the <tt>core</tt> file (assuming that the file doesn't already exist) are usually user-read and user-write, although Mac OS X sets only user-read.</p>
<p class="docText">In <a class="docLink" href="#ch10fig01">Figure 10.1</a>, the signals with a description &quot;hardware fault&quot; correspond to implementation-defined hardware faults. Many of these names are taken from the original PDP-11 implementation of the UNIX System. Check your system's manuals to determine exactly what type of error these signals correspond to.</P>
<p class="docText">We now describe each of these signals in more detail.</P>
<p><table cellspacing="0" FRAME="void" RULES="none" cellpadding="5"><colgroup><col width="100"><col width="400"></colgroup><thead></thead><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGABRT</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated by calling the <tt>abort</tt> function (<a class="docLink" href="ch10lev1sec17.html#ch10lev1sec17">Section 10.17</a>). The process terminates abnormally.</p></TD></tr><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGALRM</tt></P></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated when a timer set with the <tt>alarm</tt> function expires (see <a class="docLink" href="ch10lev1sec10.html#ch10lev1sec10">Section 10.10</a> for more details). This signal is also generated when an interval timer set by the <tt>setitimer</tt>(2) function expires.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGBUS</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This indicates an implementation-defined hardware fault. Implementations usually generate this signal on certain types of memory faults, as we describe in <a class="docLink" href="ch14lev1sec9.html#ch14lev1sec9">Section 14.9</a>.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGCANCEL</tt></p></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is used internally by the Solaris threads library. It is not meant for general use.</P></td></TR><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGCHLD</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">Whenever a process terminates or stops, the <tt>SIGCHLD</tt> signal is sent to the parent. By default, this signal is ignored, so the parent must catch this signal if it wants to be notified whenever a child's status changes. The normal action in the signal-catching function is to call one of the <tt>wait</tt> functions to fetch the child's process ID and termination status.</P>
<p class="docText">Earlier releases of System V had a similar signal named <tt>SIGCLD</tt> (without the <tt>H</tt>). The semantics of this signal were different from those of other signals, and as far back as SVR2, the manual page strongly discouraged its use in new programs. (Strangely enough, this warning disappeared in the SVR3 and SVR4 versions of the manual page.) Applications should use the standard <tt>SIGCHLD</tt> signal, but be aware that many systems define <tt>SIGCLD</tt> to be the same as <tt>SIGCHLD</tt> for backward compatibility. If you maintain software that uses <tt>SIGCLD</tt>, you need to check your system's manual page to see what semantics it follows. We discuss these two signals in <a class="docLink" href="ch10lev1sec7.html#ch10lev1sec7">Section 10.7</a>.</p></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGCONT</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This job-control signal is sent to a stopped process when it is continued. The default action is to continue a stopped process, but to ignore the signal if the process wasn't stopped. A full-screen editor, for example, might catch this signal and use the signal handler to make a note to redraw the terminal screen. See <a class="docLink" href="ch10lev1sec20.html#ch10lev1sec20">Section 10.20</a> for additional details.
</P></td></TR><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGEMT</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This indicates an implementation-defined hardware fault.
<blockquote>
<p class="docText">The name EMT comes from the PDP-11 &quot;emulator trap&quot; instruction. Not all platforms support this signal. On Linux, for example, <tt>SIGEMT</tt> is supported only for selected architectures, such as SPARC, MIPS, and PA-RISC.</P>
</blockquote>
</p></TD></tr><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><a name="idd1e69208"></a><a name="idd1e69213"></a><a name="idd1e69218"></a><a name="idd1e69223"></a><a name="idd1e69226"></a><a name="idd1e69229"></a><a name="idd1e69234"></a><a name="idd1e69239"></a><a name="idd1e69244"></a><a name="idd1e69249"></a><a name="idd1e69254"></a><a name="idd1e69259"></a><a name="idd1e69264"></a><a name="idd1e69269"></a><a name="idd1e69274"></a><a name="idd1e69279"></a><a name="idd1e69284"></a><tt>SIGFPE</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signals an arithmetic exception, such as divide by 0, floating-point overflow, and so on.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGFREEZE</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is defined only by Solaris. It is used to notify processes that need to take special action before freezing the system state, such as might happen when a system goes into hibernation or suspended mode.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGHUP</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is sent to the controlling process (session leader) associated with a controlling terminal if a disconnect is detected by the terminal interface. Referring to <a class="docLink" href="ch09lev1sec11.html#ch09fig12">Figure 9.12</a>, we see that the signal is sent to the process pointed to by the <tt>s_leader</tt> field in the <tt>session</tt> structure. This signal is generated for this condition only if the terminal's <tt>CLOCAL</tt> flag is not set. (The <tt>CLOCAL</tt> flag for a terminal is set if the attached terminal is local. The flag tells the terminal driver to ignore all modem status lines. We describe how to set this flag in <a class="docLink" href="ch18.html#ch18">Chapter 18</a>.)</P>
<p class="docText">Note that the session leader that receives this signal may be in the background; see <a class="docLink" href="ch09lev1sec6.html#ch09fig07">Figure 9.7</a> for an example. This differs from the normal terminal-generated signals (interrupt, quit, and suspend), which are always delivered to the foreground process group.</P>
<p class="docText">This signal is also generated if the session leader terminates. In this case, the signal is sent to each process in the foreground process group.</P>
<p class="docText">This signal is commonly used to notify daemon processes (<a class="docLink" href="ch13.html#ch13">Chapter 13</a>) to reread their configuration files. The reason <tt>SIGHUP</tt> is chosen for this is that a daemon should not have a controlling terminal and would normally never receive this signal.</p></TD></TR><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGILL</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal indicates that the process has executed an illegal hardware instruction.
<blockquote>
<p class="docText">4.3BSD generated this signal from the <tt>abort</tt> function. <tt>SIGABRT</tt> is now used for this.</P>
</blockquote>
</P></td></TR><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGINFO</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This BSD signal is generated by the terminal driver when we type the status key (often Control-T). This signal is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec8.html#ch09fig08">Figure 9.8</a>). This signal normally causes status information on processes in the foreground process group to be displayed on the terminal.
<blockquote>
<p class="docText">Linux doesn't provide support for <tt>SIGINFO</tt> except on the Alpha platform, where it is defined to be the same value as <tt>SIGPWR</tt>.</p>
</blockquote>
</p></td></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGINT</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated by the terminal driver when we type the interrupt key (often DELETE or Control-C). This signal is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec8.html#ch09fig08">Figure 9.8</a>). This signal is often used to terminate a runaway program, especially when it's generating a lot of unwanted output on the screen.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGIO</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal indicates an asynchronous I/O event. We discuss it in <a class="docLink" href="ch14lev1sec6.html#ch14lev2sec18">Section 14.6.2</a>.
<blockquote>
<p class="docText"><a name="idd1e69447"></a><a name="idd1e69450"></a><a name="idd1e69455"></a><a name="idd1e69460"></a><a name="idd1e69463"></a><a name="idd1e69468"></a><a name="idd1e69473"></a><a name="idd1e69478"></a><a name="idd1e69483"></a><a name="idd1e69488"></a><a name="idd1e69493"></a><a name="idd1e69498"></a><a name="idd1e69503"></a><a name="idd1e69508"></a>In <a class="docLink" href="#ch10fig01">Figure 10.1</a>, we labeled the default action for <tt>SIGIO</tt> as either &quot;terminate&quot; or &quot;ignore.&quot; Unfortunately, the default depends on the system. Under System V, <tt>SIGIO</tt> is identical to <tt>SIGPOLL</tt>, so its default action is to terminate the process. Under BSD, the default is to ignore the signal.</p>
<p class="docText">Linux 2.4.22 and Solaris 9 define <tt>SIGIO</tt> to be the same value as <tt>SIGPOLL</tt>, so the default behavior is to terminate the process. On FreeBSD 5.2.1 and Mac OS X 10.3, the default is to ignore the signal.</p>
</blockquote>
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGIOT</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">This indicates an implementation-defined hardware fault.
<blockquote>
<p class="docText">The name IOT comes from the PDP-11 mnemonic for the &quot;input/output TRAP&quot; instruction. Earlier versions of System V generated this signal from the <tt>abort</tt> function. <tt>SIGABRT</tt> is now used for this.</p>
<p class="docText">On FreeBSD 5.2.1, Linux 2.4.22, Mac OS X 10.3, and Solaris 9, <tt>SIGIOT</tt> is defined to be the same value as <tt>SIGABRT</tt>.</P>
</blockquote>
</P></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGKILL</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is one of the two that can't be caught or ignored. It provides the system administrator with a sure way to kill any process.</p></TD></TR><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGLWP</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is used internally by the Solaris threads library, and is not available for general use.</P></TD></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGPIPE</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">If we write to a pipeline but the reader has terminated, <tt>SIGPIPE</tt> is generated. We describe pipes in <a class="docLink" href="ch15lev1sec2.html#ch15lev1sec2">Section 15.2</a>. This signal is also generated when a process writes to a socket of type <tt>SOCK_STREAM</tt> that is no longer connected. We describe sockets in <a class="docLink" href="ch16.html#ch16">Chapter 16</a>.</P></td></TR><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGPOLL</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal can be generated when a specific event occurs on a pollable device. We describe this signal with the <tt>poll</tt> function in <a class="docLink" href="ch14lev1sec5.html#ch14lev2sec15">Section 14.5.2</a>. <tt>SIGPOLL</tt> originated with SVR3, and loosely corresponds to the BSD <tt>SIGIO</tt> and <tt>SIGURG</tt> signals.
<blockquote>
<p class="docText">On Linux and Solaris, <tt>SIGPOLL</tt> is defined to have the same value as <tt>SIGIO</tt>.</p>
</blockquote>
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGPROF</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated when a profiling interval timer set by the <tt>setitimer</tt>(2) function expires.</p></td></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGPWR</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is system dependent. Its main use is on a system that has an uninterruptible power supply (UPS). If power fails, the UPS takes over and the software can usually be notified. Nothing needs to be done at this point, as the system continues running on battery power. But if the battery gets low (if the power is off for an extended period), the software is usually notified again; at this point, it behooves the system to shut everything down within about 1530 seconds. This is when <tt>SIGPWR</tt> should be sent. Most systems have the process that is notified of the low-battery condition send the <tt>SIGPWR</tt> signal to the <tt>init</tt> process, and <tt>init</tt> handles the shutdown.
<blockquote>
<p class="docText">Linux 2.4.22 and Solaris 9 have entries in the <tt>inittab</tt> file for this purpose: <tt>powerfail</tt> and <tt>powerwait</tt> (or <tt>powerokwait</tt>).</P>
<p class="docText">In <a class="docLink" href="#ch10fig01">Figure 10.1</a>, we labeled the default action for <tt>SIGPWR</tt> as either &quot;terminate&quot; or &quot;ignore.&quot; Unfortunately, the default depends on the system. The default on Linux is to terminate the process. On Solaris, the signal is ignored by default.</p>
</blockquote>
</P></TD></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><a name="idd1e69735"></a><a name="idd1e69738"></a><a name="idd1e69743"></a><a name="idd1e69748"></a><a name="idd1e69751"></a><a name="idd1e69756"></a><a name="idd1e69761"></a><a name="idd1e69766"></a><a name="idd1e69771"></a><a name="idd1e69776"></a><a name="idd1e69781"></a><a name="idd1e69786"></a><a name="idd1e69791"></a><a name="idd1e69796"></a><a name="idd1e69801"></a><a name="idd1e69806"></a><a name="idd1e69811"></a><a name="idd1e69816"></a><a name="idd1e69821"></a><tt>SIGQUIT</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated by the terminal driver when we type the terminal quit key (often Control-backslash). This signal is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec8.html#ch09fig08">Figure 9.8</a>). This signal not only terminates the foreground process group (as does <tt>SIGINT</tt>), but also generates a <tt>core</tt> file.</P></td></TR><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGSEGV</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This signal indicates that the process has made an invalid memory reference.
<blockquote>
<p class="docText">The name SEGV stands for &quot;segmentation violation.&quot;</p>
</blockquote>
</p></td></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGSTKFLT</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is defined only by Linux. This signal showed up in the earliest versions of Linux, intended to be used for stack faults taken by the math coprocessor. This signal is not generated by the kernel, but remains for backward compatibility.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGSTOP</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This job-control signal stops a process. It is like the interactive stop signal (<tt>SIGTSTP</tt>), but <tt>SIGSTOP</tt> cannot be caught or ignored.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGSYS</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signals an invalid system call. Somehow, the process executed a machine instruction that the kernel thought was a system call, but the parameter with the instruction that indicates the type of system call was invalid. This might happen if you build a program that uses a new system call and you then try to run the same binary on an older version of the operating system where the system call doesn't exist.</P></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGTERM</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This is the termination signal sent by the <tt>kill</tt>(1) command by default.</P></TD></tr><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGTHAW</tt></P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is defined only by Solaris and is used to notify processes that need to take special action when the system resumes operation after being suspended.</p></TD></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGTRAP</tt></P></td><td class="docTableCell" align="left" valign="top"><p class="docText">This indicates an implementation-defined hardware fault.
<blockquote>
<p class="docText">The signal name comes from the PDP-11 TRAP instruction. Implementations often use this signal to transfer control to a debugger when a breakpoint instruction is executed.</p>
</blockquote>
</p></TD></tr><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGTSTP</tt></P></td><td class="docTableCell" align="left" valign="top"><p class="docText">This interactive stop signal is generated by the terminal driver when we type the terminal suspend key (often Control-Z). This signal is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec8.html#ch09fig08">Figure 9.8</a>).
<blockquote>
<p class="docText">Unfortunately, the term <span class="docEmphasis">stop</span> has different meanings. When discussing job control and signals, we talk about stopping and continuing jobs. The terminal driver, however, has historically used the term <span class="docEmphasis">stop</span> to refer to stopping and starting the terminal output using the Control-S and Control-Q characters. Therefore, the terminal driver calls the character that generates the interactive stop signal the suspend character, not the stop character.</p>
</blockquote>
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGTTIN</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated by the terminal driver when a process in a background process group tries to read from its controlling terminal. (Refer to the discussion of this topic in <a class="docLink" href="ch09lev1sec8.html#ch09lev1sec8">Section 9.8</a>.) As special cases, if <a name="idd1e69992"></a><a name="idd1e69997"></a><a name="idd1e70002"></a><a name="idd1e70007"></a><a name="idd1e70012"></a><a name="idd1e70015"></a><a name="idd1e70020"></a><a name="idd1e70025"></a><a name="idd1e70030"></a><a name="idd1e70035"></a><a name="idd1e70040"></a><a name="idd1e70045"></a><a name="idd1e70050"></a><a name="idd1e70055"></a><a name="idd1e70060"></a><a name="idd1e70063"></a><a name="idd1e70068"></a><a name="idd1e70073"></a><a name="idd1e70078"></a><a name="idd1e70083"></a><a name="idd1e70088"></a><a name="idd1e70093"></a><a name="idd1e70098"></a><a name="idd1e70103"></a>either (a) the reading process is ignoring or blocking this signal or (b) the process group of the reading process is orphaned, then the signal is not generated; instead, the read operation returns an error with <tt>errno</tt> set to <tt>EIO</tt>.
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGTTOU</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated by the terminal driver when a process in a background process group tries to write to its controlling terminal. (Refer to the discussion of this topic in <a class="docLink" href="ch09lev1sec8.html#ch09lev1sec8">Section 9.8</a>.) Unlike the <tt>SIGTTIN</tt> signal just described, a process has a choice of allowing background writes to the controlling terminal. We describe how to change this option in <a class="docLink" href="ch18.html#ch18">Chapter 18</a>.</p>
<p class="docText">If background writes are not allowed, then like the <tt>SIGTTIN</tt> signal, there are two special cases: if either (a) the writing process is ignoring or blocking this signal or (b) the process group of the writing process is orphaned, then the signal is not generated; instead, the write operation returns an error with <tt>errno</tt> set to <tt>EIO</tt>.</P>
<p class="docText">Regardless of whether background writes are allowed, certain terminal operations (other than writing) can also generate the <tt>SIGTTOU</tt> signal: <tt>tcsetattr</tt>, <tt>tcsendbreak</tt>, <tt>tcdrain</tt>, <tt>tcflush</tt>, <tt>tcflow</tt>, and <tt>tcsetpgrp</tt>. We describe these terminal operations in <a class="docLink" href="ch18.html#ch18">Chapter 18</a>.</P>
</TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGURG</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal notifies the process that an urgent condition has occurred. This signal is optionally generated when out-of-band data is received on a network connection.
</p></TD></TR><TR><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGUSR1</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This is a user-defined signal, for use in application programs.</P></TD></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGUSR2</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This is another user-defined signal, similar to <tt>SIGUSR1</tt>, for use in application programs.</P></td></TR><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGVTALRM</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated when a virtual interval timer set by the <tt>setitimer</tt>(2) function expires.</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGWAITING</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is used internally by the Solaris threads library, and is not available for general use.</p></td></tr><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGWINCH</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">The kernel maintains the size of the window associated with each terminal and pseudo terminal. A process can get and set the window size with the <tt>ioctl</tt> function, which we describe in <a class="docLink" href="ch18lev1sec12.html#ch18lev1sec12">Section 18.12</a>. If a process changes the window size from its previous value using the <tt>ioctl</tt> set-window-size command, the kernel generates the <tt>SIGWINCH</tt> signal for the foreground process group.</P></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGXCPU</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">The Single UNIX Specification supports the concept of resource limits as an XSI extension; refer to <a class="docLink" href="ch07lev1sec11.html#ch07lev1sec11">Section 7.11</a>. If the process exceeds its soft CPU time limit, the <tt>SIGXCPU</tt> signal is generated.
<blockquote>
<p class="docText">In <a class="docLink" href="#ch10fig01">Figure 10.1</a>, we labeled the default action for <tt>SIGXCPU</tt> as either &quot;terminate with a core file&quot; or &quot;ignore.&quot; Unfortunately, the default depends on the operating system. Linux 2.4.22 and Solaris 9 support a default action of <a name="idd1e70299"></a><a name="idd1e70302"></a><a name="idd1e70305"></a><a name="idd1e70308"></a><a name="idd1e70313"></a><a name="idd1e70318"></a><a name="idd1e70325"></a><a name="idd1e70330"></a>terminate with a core file, whereas FreeBSD 5.2.1 and Mac OS X 10.3 support a default action of ignore. The Single UNIX Specification requires that the default action be to terminate the process abnormally. Whether a core file is generated is left up to the implementation.</p>
</blockquote>
</P></TD></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGXFSZ</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">This signal is generated if the process exceeds its soft file size limit; refer to <a class="docLink" href="ch07lev1sec11.html#ch07lev1sec11">Section 7.11</a>.
<blockquote>
<p class="docText">Just as with <tt>SIGXCPU</tt>, the default action taken with <tt>SIGXFSZ</tt> depends on the operating system. On Linux 2.4.22 and Solaris 9, the default is to terminate the process and create a core file. On FreeBSD 5.2.1 and Mac OS X 10.3, the default is to be ignored. The Single UNIX Specification requires that the default action be to terminate the process abnormally. Whether a core file is generated is left up to the implementation.</P>
</blockquote>
</p></td></tr><tr><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>SIGXRES</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">This signal is defined only by Solaris. This signal is optionally used to notify processes that have exceeded a preconfigured resource value. The Solaris resource control mechanism is a general facility for controlling the use of shared resources among independent application sets.</P></td></tr></table></p><br>

<ul></ul></td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch10lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch10lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--71-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--71-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
